/*
    This file is part of the open source IVMP-MySQL project.

    IVMP-MySQL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    IVMP-MySQL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with IVMP-MySQL.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
	File: IVMP-MySQL.cpp

	Description:
		Contains the entry point for the IV-MP module. Initialises the module,
		registering functions and such.
*/

#define _CRT_SECURE_NO_WARNINGS

const char* gModuleName = "IVMP-MySQL";
const char* gModuleVersion = "R1";

#include <SDK/SDK.h>
#include <Functions.h>
#include <Logger.h>

EXPORT bool InitModule(char *moduleName)
{
	strcpy(moduleName, gModuleName);

	LogPrintf("");
	LogPrintf("  ========================================");
	LogPrintf("        %s", gModuleName);
	LogPrintf("                   Version: %s", gModuleVersion);
#ifdef _DEBUG
	LogPrintf("                  ------");
	LogPrintf("     You are running a debug version of");
	LogPrintf("                 this module!");
#endif
	LogPrintf("  ========================================");
	LogPrintf("");

	return true;
}

EXPORT void ScriptLoad(HSQUIRRELVM S)
{
	// Register functions
	RegisterFunction(S, "mysql_debug",                  plugin_mysql_debug);
	RegisterFunction(S, "mysql_connect",                plugin_mysql_connect);
	RegisterFunction(S, "mysql_close",                  plugin_mysql_close);
	RegisterFunction(S, "mysql_errno",                  plugin_mysql_errno);
	RegisterFunction(S, "mysql_ping",                   plugin_mysql_ping);
	RegisterFunction(S, "mysql_query",                  plugin_mysql_query);
	RegisterFunction(S, "mysql_store_result",           plugin_mysql_store_result);
	RegisterFunction(S, "mysql_free_result",            plugin_mysql_free_result);
	RegisterFunction(S, "mysql_num_rows",               plugin_mysql_num_rows);
	RegisterFunction(S, "mysql_num_fields",             plugin_mysql_num_fields);
	RegisterFunction(S, "mysql_fetch_row",              plugin_mysql_fetch_row);
	RegisterFunction(S, "mysql_fetch_field_row",        plugin_mysql_fetch_field_row);
	RegisterFunction(S, "mysql_escape_string",          plugin_mysql_escape_string);
}

EXPORT void ScriptUnload(HSQUIRRELVM S)
{
	Logger::Close();
}

EXPORT void Pulse()
{
}